package cn.anecansaitin.whimsy.common.register;

import cn.anecansaitin.whimsy.Whimsy;
import cn.anecansaitin.whimsy.common.network.*;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent;
import net.neoforged.neoforge.network.registration.IPayloadRegistrar;

@Mod.EventBusSubscriber(modid = Whimsy.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModChannel {

    @SubscribeEvent
    public static void channel(RegisterPayloadHandlerEvent event) {
        IPayloadRegistrar registrar = event.registrar(Whimsy.MODID).versioned(Whimsy.VERSION);
        registrar.play(RockSceptreKeyInput.ID, RockSceptreKeyInput::new, handler -> handler.server(RockSceptreKeyInput.HANDLER::handle));
        registrar.play(SimpleBlockEntityPack.ID, SimpleBlockEntityPack::new, handler -> handler.client(SimpleBlockEntityPack.HANDLER::handle));
        registrar.play(StunEffectPack.ID, StunEffectPack::new, handler -> handler.client(StunEffectPack.HANDLER::handle));
        registrar.play(KeyInputPack.ID, KeyInputPack::new, handler -> handler.server(KeyInputPack.HANDLER::handle));
        registrar.play(RocketPunchHitPack.ID, RocketPunchHitPack::new, handler -> handler.server(RocketPunchHitPack.HANDLER::handle));
        registrar.play(ServerRocketPunchStopPack.ID, ServerRocketPunchStopPack::new, handler -> handler.server(ServerRocketPunchStopPack.SERVER_HANDLER::handle));
        registrar.play(ClientRocketPunchStopPack.ID, ClientRocketPunchStopPack::new, handler -> handler.client(ClientRocketPunchStopPack.CLIENT_HANDLER::handle));
        //玩家模型动画触发包
        registrar.play(BattleModeAnimPack.ID, BattleModeAnimPack::new, handler -> handler.client(BattleModeAnimPack::clientHandler));
        //玩家切换战斗模式包
        registrar.play(BattleModeSwitchPack.ID, BattleModeSwitchPack::new, handler -> handler.server(BattleModeSwitchPack::serverHandler));
        //玩家战斗模式数据包
        registrar.play(BattleModeUpdatePack.ID, BattleModeUpdatePack::new, handler -> handler.client(BattleModeUpdatePack::clientHandler));
    }
}
